<template>
  <div class="editStoreContact pd">
    <div class="cf pd">
      <div class="fl text-right label">联系人姓名</div>
      <div class="fl input-wrap"><el-input v-model="form.name" placeholder="请输入内容"></el-input></div>
    </div>

    <div class="cf pd">
      <div class="fl text-right label">联系方式</div>
      <div class="fl input-wrap"><el-input v-model="form.contact" placeholder="请输入内容"></el-input></div>
    </div>

    <div class="text-center pd">
      <el-button @click="keepInfo" type="primary">保存</el-button>
      <el-button @click="cancel">取消</el-button>
    </div>
    <el-dialog
      title=""
      :visible.sync="successBackFlag"
      size="tiny"
      :before-close="handleClose">
      <p class="text-center">操作成功！</p>
      <p class="text-center pd">
        <el-button @click="$router.go(-1)">{{time}}s后返回列表</el-button>
      </p>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: 'editStoreContact',
    components: {
    },
    data () {
      return {
        form: {
          name: '',
          contact: ''
        },
        successBackFlag: false,
        time: 2
      }
    },
    methods: {
      cancel () {
        this.$router.go(-1)
      },
      keepInfo () {
        if (this.form.name === '') {
          this.$message({
            message: '请输入联系人姓名',
            type: 'warning'
          })
          return false
        } else if (this.form.contact === '') {
          this.$message({
            message: '请输入联系方式',
            type: 'warning'
          })
          return false
        }
        this.successBackFlag = true
        var timer = setInterval(() => {
          this.time --
          if (this.time === 0) {
            this.$router.go(-1)
            clearInterval(timer)
          }
        }, 2000)
      }
    }
  }
</script>

<style lang="less" rel="stylesheet/less" scoped>
  .editStoreContact .label{
    width: 18%;
    margin-right: 2%
  }
  .editStoreContact .input-wrap{
    width: 60%;
  }
</style>
